using System;

namespace RxjhServer
{
	public class 武功类 : IDisposable
	{
		private int _FLD_PID;

		private int _FLD_ZX;

		private int _FLD_JOB;

		private int _FLD_JOBLEVEL;

		private int _FLD_LEVEL;

		private int _FLD_MP;

		private int _FLD_NEEDEXP;

		private int _FLD_AT;

		private int _FLD_TIME;

		public int FLD_TYPE;

		private int _FLD_EFFERT;

		private int _FLD_INDEX;

		private int _FLD_攻击数量;

		private int _FLD_阶段数量;

		private int _FLD_武功类型;

		private int _FLD_冷却时间;

		private int _FLD_攻击确认时间;

		public int FLD_PID
		{
			get
			{
				return _FLD_PID;
			}
			set
			{
				_FLD_PID = value;
			}
		}

		public int FLD_ZX
		{
			get
			{
				return _FLD_ZX;
			}
			set
			{
				_FLD_ZX = value;
			}
		}

		public int FLD_JOB
		{
			get
			{
				return _FLD_JOB;
			}
			set
			{
				_FLD_JOB = value;
			}
		}

		public int FLD_JOBLEVEL
		{
			get
			{
				return _FLD_JOBLEVEL;
			}
			set
			{
				_FLD_JOBLEVEL = value;
			}
		}

		public int FLD_LEVEL
		{
			get
			{
				return _FLD_LEVEL;
			}
			set
			{
				_FLD_LEVEL = value;
			}
		}

		public int FLD_MP
		{
			get
			{
				return _FLD_MP;
			}
			set
			{
				_FLD_MP = value;
			}
		}

		public int FLD_NEEDEXP
		{
			get
			{
				return _FLD_NEEDEXP;
			}
			set
			{
				_FLD_NEEDEXP = value;
			}
		}

		public int FLD_AT
		{
			get
			{
				return _FLD_AT;
			}
			set
			{
				_FLD_AT = value;
			}
		}

		public int FLD_TIME
		{
			get
			{
				return _FLD_TIME;
			}
			set
			{
				_FLD_TIME = value;
			}
		}

		public int FLD_EFFERT
		{
			get
			{
				return _FLD_EFFERT;
			}
			set
			{
				_FLD_EFFERT = value;
			}
		}

		public int FLD_INDEX
		{
			get
			{
				return _FLD_INDEX;
			}
			set
			{
				_FLD_INDEX = value;
			}
		}

		public int FLD_攻击数量
		{
			get
			{
				return _FLD_攻击数量;
			}
			set
			{
				_FLD_攻击数量 = value;
			}
		}

		public int FLD_阶段数量
		{
			get
			{
				return _FLD_阶段数量;
			}
			set
			{
				_FLD_阶段数量 = value;
			}
		}

		public int FLD_武功类型
		{
			get
			{
				return _FLD_武功类型;
			}
			set
			{
				_FLD_武功类型 = value;
			}
		}

		public int FLD_冷却时间
		{
			get
			{
				return _FLD_冷却时间;
			}
			set
			{
				_FLD_冷却时间 = value;
			}
		}

		public int FLD_攻击确认时间
		{
			get
			{
				return _FLD_攻击确认时间;
			}
			set
			{
				_FLD_攻击确认时间 = value;
			}
		}

		public byte[] 武功ID_byte
		{
			get
			{
				return BitConverter.GetBytes(FLD_PID);
			}
		}

		public 武功类()
		{
		}

		public 武功类(int FLD_PID_)
		{
			FLD_PID = FLD_PID_;
			初始化武功(FLD_PID);
		}

		public void Dispose()
		{
		}

		public void 初始化武功(int id)
		{
			武功类 value;
			if (World.TBL_KONGFU.TryGetValue(id, out value))
			{
				FLD_AT = value.FLD_AT;
				FLD_EFFERT = value.FLD_EFFERT;
				FLD_INDEX = value.FLD_INDEX;
				FLD_JOB = value.FLD_JOB;
				FLD_JOBLEVEL = value.FLD_JOBLEVEL;
				FLD_LEVEL = value.FLD_LEVEL;
				FLD_MP = value.FLD_MP;
				FLD_NEEDEXP = value.FLD_NEEDEXP;
				FLD_PID = value.FLD_PID;
				FLD_TYPE = value.FLD_TYPE;
				FLD_ZX = value.FLD_ZX;
				FLD_攻击数量 = value.FLD_攻击数量;
				FLD_武功类型 = value.FLD_武功类型;
			}
		}

		public static 武功类 GetWg(int 人物正邪, int 人物职业, int FLD_武功类型, int FLD_INDEX)
		{
			foreach (武功类 value in World.TBL_KONGFU.Values)
			{
				if (value.FLD_ZX == 0)
				{
					if (value.FLD_JOB == 人物职业 && value.FLD_INDEX == FLD_INDEX && value.FLD_武功类型 == FLD_武功类型)
					{
						return value;
					}
				}
				else if (value.FLD_ZX == 人物正邪 && value.FLD_JOB == 人物职业 && value.FLD_INDEX == FLD_INDEX && value.FLD_武功类型 == FLD_武功类型)
				{
					return value;
				}
			}
			return null;
		}

		public static bool GetsfeWg(Players Playe, int wgid)
		{
			武功类 value;
			if (World.TBL_KONGFU.TryGetValue(wgid, out value))
			{
				if (value != null)
				{
					if (Playe.武功新[value.FLD_武功类型, value.FLD_INDEX].FLD_PID == wgid)
					{
						return true;
					}
					return false;
				}
				return false;
			}
			return false;
		}

		public static 武功类 GetWg2(Players Playe, int FLD_武功类型, int FLD_INDEX)
		{
			foreach (武功类 value in World.TBL_KONGFU.Values)
			{
				if (value.FLD_JOB == Playe.Player_Job && value.FLD_INDEX == FLD_INDEX && value.FLD_武功类型 == FLD_武功类型)
				{
					return value;
				}
			}
			return null;
		}

		public static void 学习武功书(Players Playe, ItmeClass 物品, int FLD_武功类型, int FLD_INDEX, int 包位置, int 金币)
		{
			if (物品.FLD_LEVEL > Playe.Player_Level)
			{
				Playe.系统提示("等级不足无法学习", 9, "提示");
				return;
			}
			if (物品.FLD_RESIDE1 != 0 && Playe.Player_Job != 物品.FLD_RESIDE1)
			{
				Playe.系统提示("条件不足无法学习", 9, "提示");
				return;
			}
			if (物品.FLD_ZX != 0 && 物品.FLD_ZX != Playe.Player_Zx)
			{
				Playe.系统提示("条件不足无法学习", 9, "提示");
				return;
			}
			if (物品.FLD_RESIDE1 != 0 && 物品.FLD_RESIDE1 != Playe.Player_Job)
			{
				Playe.系统提示("条件不足无法学习", 9, "提示");
				return;
			}
			if (物品.FLD_JOB_LEVEL != 0 && 物品.FLD_JOB_LEVEL > Playe.Player_Job_leve)
			{
				Playe.系统提示("条件不足无法学习", 9, "提示");
				return;
			}
			if (Playe.Player_Money < 金币)
			{
				Playe.系统提示("金币不足无法学习", 9, "提示");
				return;
			}
			武功类 wg = GetWg(Playe.Player_Zx, Playe.Player_Job, FLD_武功类型, FLD_INDEX);
			if (wg != null)
			{
				Playe.物品使用(1,包位置, 1);
				Playe.武功新[wg.FLD_武功类型, wg.FLD_INDEX] = new 武功类(wg.FLD_PID);
				Playe.Player_ExpErience -= wg.FLD_NEEDEXP;
				Playe.Player_Money -= 金币;
				Playe.更新金钱和负重();
				Playe.学习技能提示();
				Playe.更新武功和状态();
				Playe.更新经验和历练();
			}
		}

		public static void 学习武功书(Players Playe, int FLD_武功类型, int FLD_INDEX, int 包位置)
		{
			武功类 wg = GetWg(Playe.Player_Zx, Playe.Player_Job, FLD_武功类型, FLD_INDEX);
			if (wg != null && Playe.Player_ExpErience >= wg.FLD_NEEDEXP && (wg.FLD_ZX == 0 || Playe.Player_Zx == wg.FLD_ZX) && (wg.FLD_JOB == 0 || Playe.Player_Job == wg.FLD_JOB) && (wg.FLD_JOBLEVEL == 0 || Playe.Player_Job_leve >= wg.FLD_JOBLEVEL) && (wg.FLD_LEVEL == 0 || Playe.Player_Level >= wg.FLD_LEVEL))
			{
				Playe.物品使用(1,包位置, 1);
				Playe.武功新[wg.FLD_武功类型, wg.FLD_INDEX] = new 武功类(wg.FLD_PID);
				Playe.Player_ExpErience -= wg.FLD_NEEDEXP;
				Playe.学习技能提示();
				Playe.更新武功和状态();
				Playe.更新经验和历练();
			}
		}
	}
}
